package com.itheima.design.mode.template;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.util.Map;

/**
 * 主的抽象方法
 */
public abstract class NetMall {

    protected Logger logger = LoggerFactory.getLogger(NetMall.class);

    String uId;
    String pwd;

    public NetMall(String uId, String pwd) {
        this.uId = uId;
        this.pwd = pwd;
    }

    /**
     * 生产海报
     * @param skuUrl
     * @return
     */
    public String generateGoodsPoster(String skuUrl){

        //验证登录
        if(!login(uId,pwd)){
            return null;
        }
        //提取商品信息
        Map<String, String> reptile = reptile(skuUrl);
        //生成商品海报信息
        return createBase64(reptile);

    }

    // 模拟登录
    protected abstract Boolean login(String uId, String uPwd);

    // 爬虫提取商品信息(登录后的优惠价格)
    protected abstract Map<String, String> reptile(String skuUrl);

    // 生成商品海报信息
    protected abstract String createBase64(Map<String, String> goodsInfo);
}
